package com.g3.zoosite.controller;


import com.g3.zoosite.model.DwThemePark;
import com.g3.zoosite.service.IDwThemeParkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * <p>
 * 主题乐园信息表 前端控制器
 * </p>
 *
 * @author admin
 * @since 2021-09-28
 */
@Api(tags = "主题乐园信息接口")
@Slf4j  //日志打印
@RestController
@RequestMapping("/zoosite/dwThemePark")
public class DwThemeParkController {

    @Autowired
    IDwThemeParkService themeParkService;

    //查询所有主题乐园控制层方法
    @ApiOperation("查询全部主题乐园信息")
    @GetMapping("/loadThemeParks")
    public List<DwThemePark> findRareAnimals(){
        List<DwThemePark> themeParks = themeParkService.findThemeParks();
        return themeParks;
    }

    /**
     * 带数据跳转页面
     * @param id
     * @return
     */
    @ApiOperation("通过id查询主题乐园信息")
    @GetMapping("/edit/{id}")
    public ModelAndView edit(@PathVariable Integer id){
        //TODO
        //通过id去数据库查询这条数据记录
        DwThemePark themePark = themeParkService.findThemePark(id);
        //ModelAndView 使用这个来做页面跳转
        ModelAndView mv = new ModelAndView();
        mv.setViewName("/hth/hth_ztly_detail");
        mv.addObject("themePark",themePark);
        return mv;
    }
}
